package ge.info.pages;

import ge.info.domain.City;
import ge.info.domain.Street;
import ge.ktools.StringUtils;
import java.util.ArrayList;
import ge.ktapestry.pages.BasePageExt;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.event.PageEvent;
import org.apache.tapestry.annotations.InitialValue;
import java.util.List;
import org.apache.hivemind.util.PropertyUtils;
import org.apache.tapestry.IPage;

public abstract class SearchStreetdet extends BasePageExt implements PageBeginRenderListener
{

    @Persist
    public abstract Street getStreet();

    public abstract void setStreet(Street street);

     @InitialValue("null")
    public abstract Integer getStreetID();

    public abstract void setStreetID(Integer streetID);

    @Persist
    public abstract City getCity();

    public abstract void setCity(City city);

    public static int SERVICE_ID = 4;

     public void pageBeginRender(PageEvent event)
    {

        if (!event.getRequestCycle().isRewinding())
        {
            if (getStreet() == null)
            {
             setStreet(getDbExecutor().searchStreetdet(getStreetID()));
            }

            
        }

        
     }
    public void sendSMS(IRequestCycle cycle, Street street)
    {

        StringBuilder sb = new StringBuilder();

        sb.append(street.getDisplayName()).append(" ");
        if (street.getStreetIndex() != null)
        {
            sb.append(street.getStreetIndex()).append(" ");
        }
        if (street.getStreetDistrict() != null)
        {
            sb.append(street.getStreetDistrict()).append(" ");
        }
        if (street.getLocation() != null)
        {
            sb.append(street.getLocation());
        }
        getDbExecutor().insertSms(getSession(), sb.toString(), SERVICE_ID);
    }
    
    
}

